﻿/*
 * 文件名称：
 * 程序员：wangyun
 * 创建时间：2008/07/3
 * 
 * 功能说明：广告JS模板管理
 * 
 * 修改人员：
 * 
 * 修改日期：
 * 
 * 修改记录：
 */

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Whir_System_Module_Config_AdType : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        RoleHelper.IsLogin();    //登录判断
    }

    protected void rblAdType_SelectedIndexChanged(object sender, EventArgs e)
    {
        string type = rblAdType.SelectedItem.Value;
        ShowPanel(type);
    }

    private void ShowPanel(string index)
    {
        bool[] temp = new bool[8];

        for (int i = 0; i < 8; i++)
        {
            if (i == (int.Parse(index) - 1))
                temp[i] = true;
            else
                temp[i] = false;
        }

        this.Tbody1.Visible = temp[0];
        this.Tbody2.Visible = temp[1];
        this.Tbody3.Visible = temp[2];
        this.Tbody4.Visible = false;
        this.Tbody5.Visible = temp[4];
        this.Tbody6.Visible = false;
        this.Tbody7.Visible = false;
        this.Tbody8.Visible = temp[7];
    }

    protected void btnSumbit_Click(object sender, EventArgs e)
    {
        Add();
    }

    private void Add()
    {
        Whir.BLL.Whir_AdZone bll = new Whir.BLL.Whir_AdZone();
        Whir.Model.Whir_AdZone model = new Whir.Model.Whir_AdZone();

        model.Name = rblAdType.SelectedItem.Text;
        model.Description = txtDesc.Text;

        switch (rblAdType.SelectedItem.Value)
        {
            case "1":
                model.TopValue = txtAdType1ZoneTop.Text;
                model.LeftValue = txtAdType1ZoneLeft.Text;
                model.IsClose = false;
                model.Move = "";
                model.Speed = 0;
                model.JsPath = txtJSPath.Text;
                break;
            case "2":
                model.TopValue = txtAdType2ZoneTop.Text;
                model.LeftValue = txtAdType2ZoneLeft.Text;
                model.IsClose = chkAdType2IsClose.Checked;
                model.Move = rblAdType2Zone.SelectedValue;
                model.Speed = 0;
                model.JsPath = txtJSPath.Text;
                break;
            case "3":
                model.TopValue = txtAdType3ZoneTop.Text;
                model.LeftValue = txtAdType3ZoneLeft.Text;
                model.IsClose = false;
                model.Move = "";
                model.Speed = 0;
                model.JsPath = txtJSPath.Text;
                break;
            case "4":
                model.TopValue = "";
                model.LeftValue = "";
                model.IsClose = false;
                model.Move = "";
                model.Speed = 0;
                model.JsPath = txtJSPath.Text;
                break;
            case "5":
                model.TopValue = "";
                model.LeftValue = "";
                model.IsClose = chkAdType5IsClose.Checked;
                model.Move = "";
                model.Speed = 0;
                model.JsPath = txtJSPath.Text;
                break;
            case "6":
                model.TopValue = "";
                model.LeftValue = "";
                model.IsClose = false;
                model.Move = "";
                model.Speed = 0;
                model.JsPath = txtJSPath.Text;
                break;
            case "7":
                model.TopValue = "";
                model.LeftValue = "";
                model.IsClose = false;
                model.Move = "";
                model.Speed = 0;
                model.JsPath = txtJSPath.Text;
                break;
            case "8":
                model.TopValue = "";
                model.LeftValue = "";
                model.IsClose = false;
                model.Move = ddlAdType8Move.SelectedValue;
                model.Speed = Convert.ToInt32(txtAdType8Speed.Text);
                model.JsPath = txtJSPath.Text;
                break;
        }

        bll.Add(model);
    }

    private void Modfify()
    { }
}
